const defaultSteps = [
  {
    text: '销售单',
    desc: '',
  },
  {
    text: '市场单',
    desc: '',
  },
  {
    text: '画面上传',
    desc: '',
  },
  {
    text: '制作单',
    desc: '',
  },
  {
    text: '派工',
    desc: '',
  },
  {
    text: '监播发送',
    desc: '',
  },
  {
    text: '结算材料',
    desc: '',
  },
  {
    text: '开具发票',
    desc: '',
  },
  {
    text: '到款',
    desc: '',
  },
]

function genStep(row){
  let list = [...defaultSteps];
  let active = 0;
  if(!!row.payment_receive){
    active = 8;
  }else if(!!row.invoice_make_out){
    active = 7;
  }else if(!!row.settle_material_upload){
    active = 6;
  }else if(!!row.broadcast_send){
    active = 5;
  }else if(!!row.work_order_distributed){
    active = 4;
  }else if(!!row.bill_ad_make_has){
    active = 3;
  }else if(!!row.bill_market_designed){
    active = 2;
  }else if(!!row.bill_market_has){
    active = 1;
  }

  if(active > 1 && !row.bill_market_has){
    list[1].desc = '无市场单';
  }

  if(active > 2 && !row.bill_market_designed){
    list[2].desc = '无画面';
  }

  if(active > 3 && !row.bill_ad_make_has){
    list[3].desc = '无制作单';
  }

  return {
    genList: list,
    activeIndex: active
  };
}

module.exports = {
  defaultSteps,
  genStep
}